﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
         CodeBehind="AssignStudentGroup.aspx.cs" Inherits="SARS.Course.Group.AssignStudentGroup" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        function Check_Click(objRef) {
            //Get the Row based on checkbox
            var row = objRef.parentNode.parentNode;

            //Get the reference of GridView
            var GridView = row.parentNode;

            //Get all input elements in Gridview
            var inputList = GridView.getElementsByTagName("input");

            for (var i = 0; i < inputList.length; i++) {
                //The First element is the Header Checkbox
                var headerCheckBox = inputList[0];

                //Based on all or none checkboxes
                //are checked check/uncheck Header Checkbox
                var checked = true;
                if (inputList[i].type == "checkbox" && inputList[i] != headerCheckBox) {
                    if (!inputList[i].checked) {
                        checked = false;
                        break;
                    }
                }
            }
            headerCheckBox.checked = checked;

        }

        function checkAll(objRef) {
            var GridView = objRef.parentNode.parentNode.parentNode;
            var inputList = GridView.getElementsByTagName("input");
            for (var i = 0; i < inputList.length; i++) {
                if (inputList[i].type == "checkbox" && objRef != inputList[i]) {
                    if (objRef.checked) {
                        inputList[i].checked = true;
                    } else {
                        inputList[i].checked = false;
                    }
                }
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h1 id="lblHeading" class="heading1Title">
        <b>Assign Student Into GROUP</b>
    </h1>
    <asp:Panel ID="Panel1" runat="server" Direction="LeftToRight">
        <table class="style1">
            <tr>
                <td class="leftLabel">
                    <label id="Label2">
                        Course Name:
                    </label>
                </td>
                <td>
                    <asp:Label runat="server" ID="lblCourseName"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="leftLabel">
                    <label id="Label1">
                        Group Name:
                    </label>
                </td>
                <td>
                    <asp:Label runat="server" ID="lblGroupName"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="leftLabel">
                    Tutors:
                </td>
                <td>
                    <asp:Label runat="server" ID="lblTutorsName"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="gvStudentList" runat="server" AutoGenerateColumns="False" CellPadding="4"
                                  ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="20" AllowSorting="True"
                                  Width="650px" DataKeyNames="UserID" OnPageIndexChanging="gvStudentList_OnPageIndexChanging"
                                  EmptyDataText="There is no student to be assigned into this group">
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <Columns>
                            <asp:TemplateField HeaderText="Select">
                                <HeaderTemplate>
                                    <asp:CheckBox runat="server" ID="cbSelectAll" onclick="checkAll(this);" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="cbSelect" runat="server" onclick="Check_Click(this)" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="FullName" HeaderText="Full Name">
                                <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                            </asp:BoundField>
                            <asp:BoundField DataField="UserID" HeaderText="Student ID">
                                <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                            </asp:BoundField>
                            <asp:BoundField DataField="Email" HeaderText="Email">
                                <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                            </asp:BoundField>
                            <asp:BoundField DataField="Phone" HeaderText="Phone">
                                <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                            </asp:BoundField>
                            <asp:BoundField DataField="Address" HeaderText="Address">
                                <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                            </asp:BoundField>
                        </Columns>
                        <EditRowStyle BackColor="#999999" />
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#E9E7E2" />
                        <SortedAscendingHeaderStyle BackColor="#506C8C" />
                        <SortedDescendingCellStyle BackColor="#FFFDF8" />
                        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <asp:Button runat="server" ID="btnAssing" Text="Assign" OnClick="btnAssing_OnClick" />
                    &nbsp;<asp:Button runat="server" ID="btnCancel" Text="Cancel" OnClick="btnCancel_OnClick"/>
                </td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>